package com.zdb.demo.design.pattern.behavioral.iterator.demo1;

import java.util.List;

public class CourseIteratorImpl implements CourseIterator {

    private List<Course> list;
    private int position = 0;
    private Course course;

    public CourseIteratorImpl(List<Course> list) {
        this.list = list;
    }

    @Override
    public Course nextCourse() {
        course = list.get(position);
        position++;
        return course;
    }

    @Override
    public boolean lastCourse() {
        return position >= list.size();
    }
}
